from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app=Flask(__name__)

class Config:
    SQLALCHEMY_DATABASE_URI = "mysql://root:123456@127.0.0.1/flask_db"
    SQLALCHEMY_ECHO = True


app.config.from_object(Config)
db=SQLAlchemy(app)

class User(db.Model):
    __tablename__="user"
    id = db.Column(db.Integer,primary_key=True)
    username = db.Column(db.String(10),unique=True)
    password = db.Column(db.String(16))

    def __repr__(self):
        return f'(id={self.id} username="{self.username}" password="{self.password}")'

if __name__ == '__main__':
    with app.app_context():
        db.drop_all()
        db.create_all()